#!/bin/bash
# Script to list files used by each "book" (ENV-opensuse-* file)
# Author(s): Guillaume GARDET <guillaume@opensuse.org>, 2011.

pwd=`pwd`

output_type="$1";

if [ -z $1 ]; then
	output_type="text";
fi

echo "Output format: $output_type";

if [ $output_type == "text" ]; then
	for env_file in `ls ENV-opensuse-* | grep -v "html"`; do
		echo "BOOK $env_file:";
		# Use # as delimiter instead of / for sed
		daps -e $env_file projectfiles | sed -e 's#'"$pwd/xml/"'#\n#g' | sed -e 's#'"$pwd/$env_file"'#\n#g';
	done
fi

if [ $output_type == "wiki" ]; then
	for env_file in `ls ENV-opensuse-* | grep -v "html"`; do
		echo "=== Liste des fichiers relatifs Ã  $env_file ===";
		# Use # as delimiter instead of / for sed
		daps -e $env_file projectfiles | sed -e 's#'"$pwd/xml/"'#\n* #g' | sed -e 's#'"$pwd/$env_file"'# #g';
	done
fi 
